#pragma once

#include "resource.h"
#include <string>

#define CURRENT_VERSION L"2.2.0"

using namespace std;
class FilerFrogUpdater
{
private:

	wstring m_CurrentVersion;
	wstring m_NewVersion;

	void SplitVersion(const wstring& ver, int* major, int* middle, int* minor);

	bool CheckVersion(const wstring& ver);
	bool CheckVersionFromWeb(const wstring& url, const wstring& fileName);

	bool ParseConfirmFile(const wstring &filePath, wstring& version, wstring& instLink);

	bool DownloadFile(const wstring& url, const wstring& folder);
	bool DownAndRun(const wstring& url, const wstring& fileName);
	bool DownOnly(const wstring& url, const wstring& fileName, const wstring& folder);

	bool CheckVersion32();
	bool CheckVersion64();

	void DownloadAndRunInstallation32();
	void DownloadAndRunInstallation64();

	void DownloadInstallation32(const wstring& folder);
	void DownloadInstallation64(const wstring& folder);

public:

	FilerFrogUpdater();
	~FilerFrogUpdater();

	bool CheckVersion()
	{
#ifdef _WIN64
		return CheckVersion64();
#else
		return CheckVersion32();
#endif
	}

	void DownloadAndRunInstallation()
	{
#ifdef _WIN64
		DownloadAndRunInstallation64();
#else
		DownloadAndRunInstallation32();
#endif
	}

	void DownloadInstallation(const wstring& folder)
	{
#ifdef _WIN64
		DownloadInstallation64(folder);
#else
		DownloadInstallation32(folder);
#endif
	}

	void RunFile(const wstring& localFile);

	bool CheckInternetConnection();

	wstring GetLatestVersionName()
	{
		return m_NewVersion;
	}
};